home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1998 November / Freeware November 1998.img / dist / fw_emacs.idb / usr / freeware / info / emacs-4.z / emacs-4 (.txt)
GNU Info File  |  1998-10-27  |  48KB  |  881 lines

  1. This is Info file ../info/emacs, produced by Makeinfo-1.63 from the
  2. input file emacs.texi.
  3. File: emacs,  Node: M-x,  Next: Help,  Prev: Minibuffer,  Up: Top
  4. Running Commands by Name
  5. ************************
  6.    The Emacs commands that are used often or that must be quick to type
  7. are bound to keys--short sequences of characters--for convenient use.
  8. Other Emacs commands that do not need to be brief are not bound to
  9. keys; to run them, you must refer to them by name.
  10.    A command name is, by convention, made up of one or more words,
  11. separated by hyphens; for example, `auto-fill-mode' or `manual-entry'.
  12. The use of English words makes the command name easier to remember than
  13. a key made up of obscure characters, even though it is more characters
  14. to type.
  15.    The way to run a command by name is to start with `M-x', type the
  16. command name, and finish it with RET.  `M-x' uses the minibuffer to
  17. read the command name.  RET exits the minibuffer and runs the command.
  18. The string `M-x' appears at the beginning of the minibuffer as a
  19. "prompt" to remind you to enter the name of a command to be run.  *Note
  20. Minibuffer::, for full information on the features of the minibuffer.
  21.    You can use completion to enter the command name.  For example, the
  22. command `forward-char' can be invoked by name by typing
  23.      M-x forward-char RET
  24.      M-x forw TAB c RET
  25. Note that `forward-char' is the same command that you invoke with the
  26. key `C-f'.  You can run any Emacs command by name using `M-x', whether
  27. or not any keys are bound to it.  If you use `M-x' to run a command
  28. which also has a key binding, it displays a message to tell you about
  29. the key binding, before running the command.  (You can turn off this
  30. notification feature by setting the variable `suggest-key-bindings' to
  31. `nil'.)
  32.    If you type `C-g' while the command name is being read, you cancel
  33. the `M-x' command and get out of the minibuffer, ending up at top level.
  34.    To pass a numeric argument to the command you are invoking with
  35. `M-x', specify the numeric argument before the `M-x'.  `M-x' passes the
  36. argument along to the command it runs.  The argument value appears in
  37. the prompt while the command name is being read.
  38.    If the command you type has a key binding of its own, Emacs mentions
  39. this in the echo area before it runs the command.  For example, if you
  40. type `M-x forward-word', the message says that you can run the same
  41. command more easily by typing `M-f'.  You can turn off these messages
  42. by setting `suggest-key-bindings' to `nil'.  If `suggest-key-bindings'
  43. is a number, it says how long to show the message before proceeding
  44. with the command.
  45.    Normally, when describing a command that is run by name, we omit the
  46. RET that is needed to terminate the name.  Thus we might speak of `M-x
  47. auto-fill-mode' rather than `M-x auto-fill-mode RET'.  We mention the
  48. RET only when there is a need to emphasize its presence, such as when
  49. we show the command together with following arguments.
  50.    `M-x' works by running the command `execute-extended-command', which
  51. is responsible for reading the name of another command and invoking it.
  52. File: emacs,  Node: Help,  Next: Mark,  Prev: M-x,  Up: Top
  53.    Emacs provides extensive help features accessible through a single
  54. character, `C-h'.  `C-h' is a prefix key that is used only for
  55. documentation-printing commands.  The characters that you can type after
  56. `C-h' are called "help options".  One help option is `C-h'; that is how
  57. you ask for help about using `C-h'.  To cancel, type `C-g'.  The
  58. function key F1 is equivalent to `C-h'.
  59.    `C-h C-h' (`help-for-help') displays a list of the possible help
  60. options, each with a brief description.  Before you type a help option,
  61. you can use SPC or DEL to scroll through the list.
  62.    `C-h' or F1 means "help" in various other contexts as well.  For
  63. example, in `query-replace', it describes the options available.  After
  64. a prefix key, it displays a list of the alternatives that can follow
  65. the prefix key.  (A few prefix keys don't support this because they
  66. define other meanings for `C-h'.)
  67.    Most help buffers use a special major mode, Help mode, which lets you
  68. scroll conveniently with SPC and DEL.
  69. * Menu:
  70. * Help Summary::    Brief list of all Help commands.
  71. * Key Help::        Asking what a key does in Emacs.
  72. * Name Help::        Asking about a command, variable or function name.
  73. * Apropos::        Asking what pertains to a given topic.
  74. * Library Keywords::    Finding Lisp libraries by keywords (topics).
  75. * Misc Help::        Other help commands.
  76. File: emacs,  Node: Help Summary,  Next: Key Help,  Up: Help
  77. Help Summary
  78. ============
  79.    Here is a summary of the defined help commands.
  80. `C-h a REGEXP RET'
  81.      Display list of commands whose names match REGEXP
  82.      (`apropos-command').
  83. `C-h b'
  84.      Display a table of all key bindings in effect now, in this order:
  85.      minor mode bindings, major mode bindings, and global bindings
  86.      (`describe-bindings').
  87. `C-h c KEY'
  88.      Print the name of the command that KEY runs
  89.      (`describe-key-briefly').  Here `c' stands for `character'.  For
  90.      more extensive information on KEY, use `C-h k'.
  91. `C-h f FUNCTION RET'
  92.      Display documentation on the Lisp function named FUNCTION
  93.      (`describe-function').  Since commands are Lisp functions, a
  94.      command name may be used.
  95. `C-h i'
  96.      Run Info, the program for browsing documentation files (`info').
  97.      The complete Emacs manual is available on-line in Info.
  98. `C-h k KEY'
  99.      Display name and documentation of the command that KEY runs
  100.      (`describe-key').
  101. `C-h l'
  102.      Display a description of the last 100 characters you typed
  103.      (`view-lossage').
  104. `C-h m'
  105.      Display documentation of the current major mode (`describe-mode').
  106. `C-h n'
  107.      Display documentation of Emacs changes, most recent first
  108.      (`view-emacs-news').
  109. `C-h p'
  110.      Find packages by topic keyword (`finder-by-keyword').
  111. `C-h s'
  112.      Display current contents of the syntax table, plus an explanation
  113.      of what they mean (`describe-syntax').  *Note Syntax::.
  114. `C-h t'
  115.      Enter the Emacs interactive tutorial (`help-with-tutorial').
  116. `C-h v VAR RET'
  117.      Display the documentation of the Lisp variable VAR
  118.      (`describe-variable').
  119. `C-h w COMMAND RET'
  120.      Print which keys run the command named COMMAND (`where-is').
  121. `C-h C-f FUNCTION RET'
  122.      Enter Info and go to the node documenting the Emacs function
  123.      FUNCTION (`Info-goto-emacs-command-node').
  124. `C-h C-k KEY'
  125.      Enter Info and go to the node where the key sequence KEY is
  126.      documented (`Info-goto-emacs-key-command-node').
  127. `C-h C-c'
  128.      Display the copying conditions for GNU Emacs.
  129. `C-h C-d'
  130.      Display information about getting new versions of GNU Emacs.
  131. `C-h C-p'
  132.      Display information about the GNU Project.
  133. File: emacs,  Node: Key Help,  Next: Name Help,  Prev: Help Summary,  Up: Help
  134. Documentation for a Key
  135. =======================
  136.    The most basic `C-h' options are `C-h c' (`describe-key-briefly')
  137. and `C-h k' (`describe-key').  `C-h c KEY' prints in the echo area the
  138. name of the command that KEY is bound to.  For example, `C-h c C-f'
  139. prints `forward-char'.  Since command names are chosen to describe what
  140. the commands do, this is a good way to get a very brief description of
  141. what KEY does.
  142.    `C-h k KEY' is similar but gives more information: it displays the
  143. documentation string of the command as well as its name.  This is too
  144. big for the echo area, so a window is used for the display.
  145.    `C-h c' and `C-h k' work for any sort of key sequences, including
  146. function keys and mouse events.
  147. File: emacs,  Node: Name Help,  Next: Apropos,  Prev: Key Help,  Up: Help
  148. Help by Command or Variable Name
  149. ================================
  150.    `C-h f' (`describe-function') reads the name of a Lisp function
  151. using the minibuffer, then displays that function's documentation string
  152. in a window.  Since commands are Lisp functions, you can use this to get
  153. the documentation of a command that you know by name.  For example,
  154.      C-h f auto-fill-mode RET
  155. displays the documentation of `auto-fill-mode'.  This is the only way
  156. to get the documentation of a command that is not bound to any key (one
  157. which you would normally run using `M-x').
  158.    `C-h f' is also useful for Lisp functions that you are planning to
  159. use in a Lisp program.  For example, if you have just written the
  160. expression `(make-vector len)' and want to check that you are using
  161. `make-vector' properly, type `C-h f make-vector RET'.  Because `C-h f'
  162. allows all function names, not just command names, you may find that
  163. some of your favorite abbreviations that work in `M-x' don't work in
  164. `C-h f'.  An abbreviation may be unique among command names yet fail to
  165. be unique when other function names are allowed.
  166.    The function name for `C-h f' to describe has a default which is
  167. used if you type RET leaving the minibuffer empty.  The default is the
  168. function called by the innermost Lisp expression in the buffer around
  169. point, *provided* that is a valid, defined Lisp function name.  For
  170. example, if point is located following the text `(make-vector (car x)',
  171. the innermost list containing point is the one that starts with
  172. `(make-vector', so the default is to describe the function
  173. `make-vector'.
  174.    `C-h f' is often useful just to verify that you have the right
  175. spelling for the function name.  If `C-h f' mentions a name from the
  176. buffer as the default, that name must be defined as a Lisp function.  If
  177. that is all you want to know, just type `C-g' to cancel the `C-h f'
  178. command, then go on editing.
  179.    `C-h w COMMAND RET' tells you what keys are bound to COMMAND.  It
  180. prints a list of the keys in the echo area.  If it says the command is
  181. not on any key, you must use `M-x' to run it.  `C-h w' runs the command
  182. `where-is'.
  183.    `C-h v' (`describe-variable') is like `C-h f' but describes Lisp
  184. variables instead of Lisp functions.  Its default is the Lisp symbol
  185. around or before point, but only if that is the name of a known Lisp
  186. variable.  *Note Variables::.
  187. File: emacs,  Node: Apropos,  Next: Library Keywords,  Prev: Name Help,  Up: Help
  188. Apropos
  189. =======
  190.    A more sophisticated sort of question to ask is, "What are the
  191. commands for working with files?"  To ask this question, type `C-h a
  192. file RET', which displays a list of all command names that contain
  193. `file', including `copy-file', `find-file', and so on.  With each
  194. command name appears a brief description of how to use the command, and
  195. what keys you can currently invoke it with.  For example, it would say
  196. that you can invoke `find-file' by typing `C-x C-f'.  The `a' in `C-h
  197. a' stands for `Apropos'; `C-h a' runs the command `apropos-command'.
  198. This command does not check user variables by default; specify a
  199. numeric argument if you want it to check them.
  200.    Because `C-h a' looks only for functions whose names contain the
  201. string which you specify, you must use ingenuity in choosing the
  202. string.  If you are looking for commands for killing backwards and `C-h
  203. a kill-backwards RET' doesn't reveal any, don't give up.  Try just
  204. `kill', or just `backwards', or just `back'.  Be persistent.  Also note
  205. that you can use a regular expression as the argument, for more
  206. flexibility (*note Regexps::.).
  207.    Here is a set of arguments to give to `C-h a' that covers many
  208. classes of Emacs commands, since there are strong conventions for naming
  209. the standard Emacs commands.  By giving you a feel for the naming
  210. conventions, this set should also serve to aid you in developing a
  211. technique for picking `apropos' strings.
  212.      char, line, word, sentence, paragraph, region, page, sexp, list,
  213.      defun, rect, buffer, frame, window, face, file, dir, register,
  214.      mode, beginning, end, forward, backward, next, previous, up, down,
  215.      search, goto, kill, delete, mark, insert, yank, fill, indent,
  216.      case, change, set, what, list, find, view, describe, default.
  217.    To list all Lisp symbols that contain a match for a regexp, not just
  218. the ones that are defined as commands, use the command `M-x apropos'
  219. instead of `C-h a'.  This command does not check key bindings by
  220. default; specify a numeric argument if you want it to check them.
  221.    The `apropos-documentation' command is like `apropos' except that it
  222. searches documentation strings as well as symbol names for matches for
  223. the specified regular expression.
  224.    The `apropos-value' command is like `apropos' except that it
  225. searches symbols' values for matches for the specified regular
  226. expression.  This command does not check function definitions or
  227. property lists by default; specify a numeric argument if you want it to
  228. check them.
  229.    If you want more information about a function definition, variable or
  230. symbol property listed in the Apropos buffer, you can click on it with
  231. `Mouse-2' or move there and type RET.
  232. File: emacs,  Node: Library Keywords,  Next: Misc Help,  Prev: Apropos,  Up: Help
  233. Keyword Search for Lisp Libraries
  234. =================================
  235.    The `C-h p' command lets you search the standard Emacs Lisp
  236. libraries by topic keywords.  Here is a partial list of keywords you can
  237. `abbrev'
  238.      Abbreviation handling, typing shortcuts, macros.
  239. `bib'
  240.      Support for the bibliography processor `bib'.
  241.      C and C++ language support.
  242. `calendar'
  243.      Calendar and time management support.
  244. `comm'
  245.      Communications, networking, remote access to files.
  246. `data'
  247.      Support for editing files of data.
  248. `docs'
  249.      Support for Emacs documentation.
  250. `emulations'
  251.      Emulations of other editors.
  252. `extensions'
  253.      Emacs Lisp language extensions.
  254. `faces'
  255.      Support for using faces (fonts and colors; *note Faces::.).
  256. `frames'
  257.      Support for Emacs frames and window systems.
  258. `games'
  259.      Games, jokes and amusements.
  260. `hardware'
  261.      Support for interfacing with exotic hardware.
  262. `help'
  263.      Support for on-line help systems.
  264. `hypermedia'
  265.      Support for links within text, or other media types.
  266. `i18n'
  267.      Internationalization and alternate character-set support.
  268. `internal'
  269.      Code for Emacs internals, build process, defaults.
  270. `languages'
  271.      Specialized modes for editing programming languages.
  272. `lisp'
  273.      Support for using Lisp (including Emacs Lisp).
  274. `local'
  275.      Libraries local to your site.
  276. `maint'
  277.      Maintenance aids for the Emacs development group.
  278. `mail'
  279.      Modes for electronic-mail handling.
  280. `matching'
  281.      Searching and matching.
  282. `news'
  283.      Support for netnews reading and posting.
  284. `non-text'
  285.      Support for editing files that are not ordinary text.
  286. `oop'
  287.      Support for object-oriented programming.
  288. `outlines'
  289.      Hierarchical outlining.
  290. `processes'
  291.      Process, subshell, compilation, and job control support.
  292. `terminals'
  293.      Support for terminal types.
  294. `tex'
  295.      Support for the TeX formatter.
  296. `tools'
  297.      Programming tools.
  298. `unix'
  299.      Front-ends/assistants for, or emulators of, Unix features.
  300. `vms'
  301.      Support code for VMS.
  302.      Word processing.
  303. File: emacs,  Node: Misc Help,  Prev: Library Keywords,  Up: Help
  304. Other Help Commands
  305. ===================
  306.    `C-h i' (`info') runs the Info program, which is used for browsing
  307. through structured documentation files.  The entire Emacs manual is
  308. available within Info.  Eventually all the documentation of the GNU
  309. system will be available.  Type `h' after entering Info to run a
  310. tutorial on using Info.
  311.    There are two special help commands for accessing Emacs documentation
  312. through Info.  `C-h C-f FUNCTION RET' enters Info and goes straight to
  313. the documentation of the Emacs function FUNCTION.  `C-h C-k KEY' enters
  314. Info and goes straight to the documentation of the key KEY.  These two
  315. keys run the commands `Info-goto-emacs-command-node' and
  316. `Info-goto-emacs-key-command-node'.
  317.    If something surprising happens, and you are not sure what commands
  318. you typed, use `C-h l' (`view-lossage').  `C-h l' prints the last 100
  319. command characters you typed in.  If you see commands that you don't
  320. know, you can use `C-h c' to find out what they do.
  321.    Emacs has numerous major modes, each of which redefines a few keys
  322. and makes a few other changes in how editing works.  `C-h m'
  323. (`describe-mode') prints documentation on the current major mode, which
  324. normally describes all the commands that are changed in this mode.
  325.    `C-h b' (`describe-bindings') and `C-h s' (`describe-syntax')
  326. present other information about the current Emacs mode.  `C-h b'
  327. displays a list of all the key bindings now in effect; the local
  328. bindings defined by the current minor modes first, then the local
  329. bindings defined by the current major mode, and finally the global
  330. bindings (*note Key Bindings::.).  `C-h s' displays the contents of the
  331. syntax table, with explanations of each character's syntax (*note
  332. Syntax::.).
  333.    You can get a similar list for a particular prefix key by typing
  334. `C-h' after the prefix key.  (There are a few prefix keys for which
  335. this does not work--those that provide their own bindings for `C-h'.
  336. One of these is ESC, because `ESC C-h' is actually `C-M-h', which marks
  337. a defun.)
  338.    The other `C-h' options display various files of useful information.
  339. `C-h C-w' displays the full details on the complete absence of
  340. warranty for GNU Emacs.  `C-h n' (`view-emacs-news') displays the file
  341. `emacs/etc/NEWS', which contains documentation on Emacs changes
  342. arranged chronologically.  `C-h t' (`help-with-tutorial') displays the
  343. learn-by-doing Emacs tutorial.  `C-h C-c' (`describe-copying') displays
  344. the file `emacs/etc/COPYING', which tells you the conditions you must
  345. obey in distributing copies of Emacs.  `C-h C-d'
  346. (`describe-distribution') displays the file `emacs/etc/DISTRIB', which
  347. tells you how you can order a copy of the latest version of Emacs.
  348. `C-h C-p' (`describe-project') displays general information about the
  349. GNU Project.
  350. File: emacs,  Node: Mark,  Next: Killing,  Prev: Help,  Up: Top
  351. The Mark and the Region
  352. ***********************
  353.    Many Emacs commands operate on an arbitrary contiguous part of the
  354. current buffer.  To specify the text for such a command to operate on,
  355. you set "the mark" at one end of it, and move point to the other end.
  356. The text between point and the mark is called "the region".  Emacs
  357. highlights the region whenever there is one, if you enable Transient
  358. Mark mode (*note Transient Mark::.).
  359.    You can move point or the mark to adjust the boundaries of the
  360. region.  It doesn't matter which one is set first chronologically, or
  361. which one comes earlier in the text.  Once the mark has been set, it
  362. remains where you put it until you set it again at another place.  Each
  363. Emacs buffer has its own mark, so that when you return to a buffer that
  364. had been selected previously, it has the same mark it had before.
  365.    Many commands that insert text, such as `C-y' (`yank') and `M-x
  366. insert-buffer', position point and the mark at opposite ends of the
  367. inserted text, so that the region contains the text just inserted.
  368.    Aside from delimiting the region, the mark is also useful for
  369. remembering a spot that you may want to go back to.  To make this
  370. feature more useful, each buffer remembers 16 previous locations of the
  371. mark in the "mark ring".
  372. * Menu:
  373. * Setting Mark::    Commands to set the mark.
  374. * Transient Mark::    How to make Emacs highlight the region-
  375.               when there is one.
  376. * Using Region::    Summary of ways to operate on contents of the region.
  377. * Marking Objects::    Commands to put region around textual units.
  378. * Mark Ring::       Previous mark positions saved so you can go back there.
  379. * Global Mark Ring::    Previous mark positions in various buffers.
  380. File: emacs,  Node: Setting Mark,  Next: Transient Mark,  Up: Mark
  381. Setting the Mark
  382. ================
  383.    Here are some commands for setting the mark:
  384. `C-SPC'
  385.      Set the mark where point is (`set-mark-command').
  386. `C-@'
  387.      The same.
  388. `C-x C-x'
  389.      Interchange mark and point (`exchange-point-and-mark').
  390. `Drag-Mouse-1'
  391.      Set point and the mark around the text you drag across.
  392. `Mouse-3'
  393.      Set the mark where point is, then move point to where you click
  394.      (`mouse-save-then-kill').
  395.    For example, suppose you wish to convert part of the buffer to all
  396. upper-case, using the `C-x C-u' (`upcase-region') command which
  397. operates on the text in the region.  You can first go to the beginning
  398. of the text to be capitalized, type `C-SPC' to put the mark there, move
  399. to the end, and then type `C-x C-u'.  Or, you can set the mark at the
  400. end of the text, move to the beginning, and then type `C-x C-u'.
  401.    The most common way to set the mark is with the `C-SPC' command
  402. (`set-mark-command').  This sets the mark where point is.  Then you can
  403. move point away, leaving the mark behind.
  404.    There are two ways to set the mark with the mouse.  You can drag
  405. mouse button one across a range of text; that puts point where you
  406. release the mouse button, and sets the mark at the other end of that
  407. range.  Or you can click mouse button three, which sets the mark at
  408. point (like `C-SPC') and them moves point (like `Mouse-1').  Both of
  409. these methods copy the region into the kill ring in addition to setting
  410. the mark; that gives behavior consistent with other window-driven
  411. applications, but if you don't want to modify the kill ring, you must
  412. use keyboard commands to set the mark.  *Note Mouse Commands::.
  413.    Ordinary terminals have only one cursor, so there is no way for Emacs
  414. to show you where the mark is located.  You have to remember.  The usual
  415. solution to this problem is to set the mark and then use it soon, before
  416. you forget where it is.  Alternatively, you can see where the mark is
  417. with the command `C-x C-x' (`exchange-point-and-mark') which puts the
  418. mark where point was and point where the mark was.  The extent of the
  419. region is unchanged, but the cursor and point are now at the previous
  420. position of the mark.  In Transient Mark mode, this command reactivates
  421. the mark.
  422.    `C-x C-x' is also useful when you are satisfied with the position of
  423. point but want to move the mark; do `C-x C-x' to put point at that end
  424. of the region, and then move it.  A second use of `C-x C-x', if
  425. necessary, puts the mark at the new position with point back at its
  426. original position.
  427.    There is no such character as `C-SPC' in ASCII; when you type SPC
  428. while holding down CTRL, what you get on most ordinary terminals is the
  429. character `C-@'.  This key is actually bound to `set-mark-command'.
  430. But unless you are unlucky enough to have a terminal where typing
  431. `C-SPC' does not produce `C-@', you might as well think of this
  432. character as `C-SPC'.  Under X, `C-SPC' is actually a distinct
  433. character, but its binding is still `set-mark-command'.
  434. File: emacs,  Node: Transient Mark,  Next: Using Region,  Prev: Setting Mark,  Up: Mark
  435. Transient Mark Mode
  436. ===================
  437.    Emacs can highlight the current region, using X Windows.  But
  438. normally it does not.  Why not?
  439.    Highlighting the region doesn't work well ordinarily in Emacs,
  440. because once you have set a mark, there is *always* a region (in that
  441. buffer).  And highlighting the region all the time would be a nuisance.
  442.    You can turn on region highlighting by enabling Transient Mark mode.
  443. This is a more rigid mode of operation in which the region "lasts" only
  444. temporarily, so you must set up a region for each command that uses
  445. one.  In Transient Mark mode, most of the time there is no region;
  446. therefore, highlighting the region when it exists is convenient.
  447.    To enable Transient Mark mode, type `M-x transient-mark-mode'.  This
  448. command toggles the mode, so you can repeat the command to turn off the
  449. mode.
  450.    Here are the details of Transient Mark mode:
  451.    * To set the mark, type `C-SPC' (`set-mark-command').  This makes
  452.      the mark active; as you move point, you will see the region
  453.      highlighting change in extent.
  454.    * The mouse commands for specifying the mark also make it active.
  455.      So do keyboard commands whose purpose is to specify a region,
  456.      including `M-@', `C-M-@', `M-h', `C-M-h', `C-x C-p', and `C-x h'.
  457.    * When the mark is active, you can execute commands that operate on
  458.      the region, such as killing, indentation, or writing to a file.
  459.    * Any change to the buffer, such as inserting or deleting a
  460.      character, deactivates the mark.  This means any subsequent
  461.      command that operates on a region will get an error and refuse to
  462.      operate.  You can make the region active again by typing `C-x C-x'.
  463.    * Commands like `M->' and `C-s' that "leave the mark behind" in
  464.      addition to some other primary purpose do not activate the new
  465.      mark.  You can activate the new region by executing `C-x C-x'
  466.      (`exchange-point-and-mark').
  467.    * `C-s' when the mark is active does not alter the mark.
  468.    * Quitting with `C-g' deactivates the mark.
  469.    Transient Mark mode is also sometimes known as "Zmacs mode" because
  470. the Zmacs editor on the MIT Lisp Machine handled the mark in a similar
  471.    When multiple windows show the same buffer, they can have different
  472. regions, because they can have different values of point (though they
  473. all share common one mark position).  In Transient Mark mode, each
  474. window highlights its own region.  The part that is highlighted in the
  475. selected window is the region that editing commands use.  *Note
  476. Windows::.
  477.    When Transient Mark mode is not enabled, every command that sets the
  478. mark also activates it, and nothing ever deactivates it.
  479.    If the variable `mark-even-if-inactive' is non-`nil' in Transient
  480. Mark mode, then commands can use the mark and the region even when it
  481. is inactive.  Region highlighting appears and disappears just as it
  482. normally does in Transient Mark mode, but the mark doesn't really go
  483. away when the highlighting disappears.
  484. File: emacs,  Node: Using Region,  Next: Marking Objects,  Prev: Transient Mark,  Up: Mark
  485. Operating on the Region
  486. =======================
  487.    Once you have a region and the mark is active, here are some of the
  488. ways you can operate on the region:
  489.    * Kill it with `C-w' (*note Killing::.).
  490.    * Save it in a register with `C-x r s' (*note Registers::.).
  491.    * Save it in a buffer or a file (*note Accumulating Text::.).
  492.    * Convert case with `C-x C-l' or `C-x C-u' (*note Case::.).
  493.    * Indent it with `C-x TAB' or `C-M-\' (*note Indentation::.).
  494.    * Fill it as text with `M-x fill-region' (*note Filling::.).
  495.    * Print hardcopy with `M-x print-region' (*note Hardcopy::.).
  496.    * Evaluate it as Lisp code with `M-x eval-region' (*note Lisp
  497.      Eval::.).
  498.    Most commands that operate on the text in the region have the word
  499. `region' in their names.
  500. File: emacs,  Node: Marking Objects,  Next: Mark Ring,  Prev: Using Region,  Up: Mark
  501. Commands to Mark Textual Objects
  502. ================================
  503.    Here are the commands for placing point and the mark around a textual
  504. object such as a word, list, paragraph or page.
  505. `M-@'
  506.      Set mark after end of next word (`mark-word').  This command and
  507.      the following one do not move point.
  508. `C-M-@'
  509.      Set mark after end of next Lisp expression (`mark-sexp').
  510. `M-h'
  511.      Put region around current paragraph (`mark-paragraph').
  512. `C-M-h'
  513.      Put region around current Lisp defun (`mark-defun').
  514. `C-x h'
  515.      Put region around entire buffer (`mark-whole-buffer').
  516. `C-x C-p'
  517.      Put region around current page (`mark-page').
  518.    `M-@' (`mark-word') puts the mark at the end of the next word, while
  519. `C-M-@' (`mark-sexp') puts it at the end of the next Lisp expression.
  520. These commands handle arguments just like `M-f' and `C-M-f'.
  521.    Other commands set both point and mark, to delimit an object in the
  522. buffer.  For example, `M-h' (`mark-paragraph') moves point to the
  523. beginning of the paragraph that surrounds or follows point, and puts
  524. the mark at the end of that paragraph (*note Paragraphs::.).  It
  525. prepares the region so you can indent, case-convert, or kill a whole
  526. paragraph.
  527.    `C-M-h' (`mark-defun') similarly puts point before and the mark
  528. after the current or following defun (*note Defuns::.).  `C-x C-p'
  529. (`mark-page') puts point before the current page, and mark at the end
  530. (*note Pages::.).  The mark goes after the terminating page delimiter
  531. (to include it), while point goes after the preceding page delimiter
  532. (to exclude it).  A numeric argument specifies a later page (if
  533. positive) or an earlier page (if negative) instead of the current page.
  534.    Finally, `C-x h' (`mark-whole-buffer') sets up the entire buffer as
  535. the region, by putting point at the beginning and the mark at the end.
  536.    In Transient Mark mode, all of these commands activate the mark.
  537. File: emacs,  Node: Mark Ring,  Next: Global Mark Ring,  Prev: Marking Objects,  Up: Mark
  538. The Mark Ring
  539. =============
  540.    Aside from delimiting the region, the mark is also useful for
  541. remembering a spot that you may want to go back to.  To make this
  542. feature more useful, each buffer remembers 16 previous locations of the
  543. mark, in the "mark ring".  Commands that set the mark also push the old
  544. mark onto this ring.  To return to a marked location, use `C-u C-SPC'
  545. (or `C-u C-@'); this is the command `set-mark-command' given a numeric
  546. argument.  It moves point to where the mark was, and restores the mark
  547. from the ring of former marks.  Thus, repeated use of this command
  548. moves point to all of the old marks on the ring, one by one.  The mark
  549. positions you move through in this way are not lost; they go to the end
  550. of the ring.
  551.    Each buffer has its own mark ring.  All editing commands use the
  552. current buffer's mark ring.  In particular, `C-u C-SPC' always stays in
  553. the same buffer.
  554.    Many commands that can move long distances, such as `M-<'
  555. (`beginning-of-buffer'), start by setting the mark and saving the old
  556. mark on the mark ring.  This is to make it easier for you to move back
  557. later.  Searches set the mark if they move point.  You can tell when a
  558. command sets the mark because it displays `Mark Set' in the echo area.
  559.    If you want to move back to the same place over and over, the mark
  560. ring may not be convenient enough.  If so, you can record the position
  561. in a register for later retrieval (*note RegPos::.).
  562.    The variable `mark-ring-max' specifies the maximum number of entries
  563. to keep in the mark ring.  If that many entries exist and another one
  564. is pushed, the last one in the list is discarded.  Repeating `C-u
  565. C-SPC' circulates through the positions currently in the ring.
  566.    The variable `mark-ring' holds the mark ring itself, as a list of
  567. marker objects in the order most recent first.  This variable is local
  568. in every buffer.
  569. File: emacs,  Node: Global Mark Ring,  Prev: Mark Ring,  Up: Mark
  570. The Global Mark Ring
  571. ====================
  572.    In addition to the ordinary mark ring that belongs to each buffer,
  573. Emacs has a single "global mark ring".  It records a sequence of
  574. buffers in which you have recently set the mark, so you can go back to
  575. those buffers.
  576.    Setting the mark always makes an entry on the current buffer's mark
  577. ring.  If you have switched buffers since the previous mark setting, the
  578. new mark position makes an entry on the global mark ring also.  The
  579. result is that the global mark ring records a sequence of buffers that
  580. you have been in, and, for each buffer, a place where you set the mark.
  581.    The command `C-x C-SPC' (`pop-global-mark') jumps to the buffer and
  582. position of the latest entry in the global ring.  It also rotates the
  583. ring, so that successive uses of `C-x C-SPC' take you to earlier and
  584. earlier buffers.
  585. File: emacs,  Node: Killing,  Next: Yanking,  Prev: Mark,  Up: Top
  586. Deletion and Killing
  587. ====================
  588.    Most commands which erase text from the buffer save it in the kill
  589. ring so that you can move or copy it to other parts of the buffer.
  590. These commands are known as "kill" commands.  The rest of the commands
  591. that erase text do not save it in the kill ring; they are known as
  592. "delete" commands.  (This distinction is made only for erasure of text
  593. in the buffer.)  If you do a kill or delete command by mistake, you can
  594. use the `C-x u' (`undo') command to undo it (*note Undo::.).
  595.    The delete commands include `C-d' (`delete-char') and DEL
  596. (`delete-backward-char'), which delete only one character at a time,
  597. and those commands that delete only spaces or newlines.  Commands that
  598. can destroy significant amounts of nontrivial data generally kill.  The
  599. commands' names and individual descriptions use the words `kill' and
  600. `delete' to say which they do.
  601. * Menu:
  602. * Deletion::            Commands for deleting small amounts of text and
  603.                           blank areas.
  604. * Killing by Lines::    How to kill entire lines of text at one time.
  605. * Other Kill Commands:: Commands to kill large regions of text and
  606.                           syntactic units such as words and sentences.
  607. File: emacs,  Node: Deletion,  Next: Killing by Lines,  Up: Killing
  608. Deletion
  609. --------
  610. `C-d'
  611.      Delete next character (`delete-char').
  612. `DEL'
  613.      Delete previous character (`delete-backward-char').
  614. `M-\'
  615.      Delete spaces and tabs around point (`delete-horizontal-space').
  616. `M-SPC'
  617.      Delete spaces and tabs around point, leaving one space
  618.      (`just-one-space').
  619. `C-x C-o'
  620.      Delete blank lines around the current line (`delete-blank-lines').
  621. `M-^'
  622.      Join two lines by deleting the intervening newline, along with any
  623.      indentation following it (`delete-indentation').
  624.    The most basic delete commands are `C-d' (`delete-char') and DEL
  625. (`delete-backward-char').  `C-d' deletes the character after point, the
  626. one the cursor is "on top of".  This doesn't move point.  DEL deletes
  627. the character before the cursor, and moves point back.  You can delete
  628. newlines like any other characters in the buffer; deleting a newline
  629. joins two lines.  Actually, `C-d' and DEL aren't always delete
  630. commands; when given arguments, they kill instead, since they can erase
  631. more than one character this way.
  632.    The other delete commands are those which delete only whitespace
  633. characters: spaces, tabs and newlines.  `M-\'
  634. (`delete-horizontal-space') deletes all the spaces and tab characters
  635. before and after point.  `M-SPC' (`just-one-space') does likewise but
  636. leaves a single space after point, regardless of the number of spaces
  637. that existed previously (even zero).
  638.    `C-x C-o' (`delete-blank-lines') deletes all blank lines after the
  639. current line.  If the current line is blank, it deletes all blank lines
  640. preceding the current line as well (leaving one blank line, the current
  641. line).
  642.    `M-^' (`delete-indentation') joins the current line and the previous
  643. line, by deleting a newline and all surrounding spaces, usually leaving
  644. a single space.  *Note M-^: Indentation.
  645. File: emacs,  Node: Killing by Lines,  Next: Other Kill Commands,  Prev: Deletion,  Up: Killing
  646. Killing by Lines
  647. ----------------
  648. `C-k'
  649.      Kill rest of line or one or more lines (`kill-line').
  650.    The simplest kill command is `C-k'.  If given at the beginning of a
  651. line, it kills all the text on the line, leaving it blank.  When used
  652. on a blank line, it kills the whole line including its newline.  To kill
  653. an entire non-blank line, go to the beginning and type `C-k' twice.
  654.    More generally, `C-k' kills from point up to the end of the line,
  655. unless it is at the end of a line.  In that case it kills the newline
  656. following point, thus merging the next line into the current one.
  657. Spaces and tabs that you can't see at the end of the line are ignored
  658. when deciding which case applies, so if point appears to be at the end
  659. of the line, you can be sure `C-k' will kill the newline.
  660.    When `C-k' is given a positive argument, it kills that many lines
  661. and the newlines that follow them (however, text on the current line
  662. before point is spared).  With a negative argument -N, it kills N lines
  663. preceding the current line (together with the text on the current line
  664. before point).  Thus, `C-u - 2 C-k' at the front of a line kills the
  665. two previous lines.
  666.    `C-k' with an argument of zero kills the text before point on the
  667. current line.
  668.    If the variable `kill-whole-line' is non-`nil', `C-k' at the very
  669. beginning of a line kills the entire line including the following
  670. newline.  This variable is normally `nil'.
  671. File: emacs,  Node: Other Kill Commands,  Prev: Killing by Lines,  Up: Killing
  672. Other Kill Commands
  673. -------------------
  674. `C-w'
  675.      Kill region (from point to the mark) (`kill-region').
  676. `M-d'
  677.      Kill word (`kill-word').  *Note Words::.
  678. `M-DEL'
  679.      Kill word backwards (`backward-kill-word').
  680. `C-x DEL'
  681.      Kill back to beginning of sentence (`backward-kill-sentence').
  682.      *Note Sentences::.
  683. `M-k'
  684.      Kill to end of sentence (`kill-sentence').
  685. `C-M-k'
  686.      Kill sexp (`kill-sexp').  *Note Lists::.
  687. `M-z CHAR'
  688.      Kill through the next occurrence of CHAR (`zap-to-char').
  689.    A kill command which is very general is `C-w' (`kill-region'), which
  690. kills everything between point and the mark.  With this command, you
  691. can kill any contiguous sequence of characters, if you first set the
  692. region around them.
  693.    A convenient way of killing is combined with searching: `M-z'
  694. (`zap-to-char') reads a character and kills from point up to (and
  695. including) the next occurrence of that character in the buffer.  A
  696. numeric argument acts as a repeat count.  A negative argument means to
  697. search backward and kill text before point.
  698.    Other syntactic units can be killed: words, with `M-DEL' and `M-d'
  699. (*note Words::.); sexps, with `C-M-k' (*note Lists::.); and sentences,
  700. with `C-x DEL' and `M-k' (*note Sentences::.).
  701.    You can use kill commands in read-only buffers.  They don't actually
  702. change the buffer, and they beep to warn you of that, but they do copy
  703. the text you tried to kill into the kill ring, so you can yank it into
  704. other buffers.  Most of the kill commands move point across the text
  705. they copy in this way, so that successive kill commands build up a
  706. single kill ring entry as usual.
  707. File: emacs,  Node: Yanking,  Next: Accumulating Text,  Prev: Killing,  Up: Top
  708. Yanking
  709. =======
  710.    "Yanking" means reinserting text previously killed.  This is what
  711. some systems call "pasting".  The usual way to move or copy text is to
  712. kill it and then yank it elsewhere one or more times.
  713. `C-y'
  714.      Yank last killed text (`yank').
  715. `M-y'
  716.      Replace text just yanked with an earlier batch of killed text
  717.      (`yank-pop').
  718. `M-w'
  719.      Save region as last killed text without actually killing it
  720.      (`kill-ring-save').
  721. `C-M-w'
  722.      Append next kill to last batch of killed text (`append-next-kill').
  723. * Menu:
  724. * Kill Ring::        Where killed text is stored.  Basic yanking.
  725. * Appending Kills::    Several kills in a row all yank together.
  726. * Earlier Kills::    Yanking something killed some time ago.
  727. File: emacs,  Node: Kill Ring,  Next: Appending Kills,  Up: Yanking
  728. The Kill Ring
  729. -------------
  730.    All killed text is recorded in the "kill ring", a list of blocks of
  731. text that have been killed.  There is only one kill ring, shared by all
  732. buffers, so you can kill text in one buffer and yank it in another
  733. buffer.  This is the usual way to move text from one file to another.
  734. (*Note Accumulating Text::, for some other ways.)
  735.    The command `C-y' (`yank') reinserts the text of the most recent
  736. kill.  It leaves the cursor at the end of the text.  It sets the mark at
  737. the beginning of the text.  *Note Mark::.
  738.    `C-u C-y' leaves the cursor in front of the text, and sets the mark
  739. after it.  This happens only if the argument is specified with just a
  740. `C-u', precisely.  Any other sort of argument, including `C-u' and
  741. digits, specifies an earlier kill to yank (*note Earlier Kills::.).
  742.    To copy a block of text, you can use `M-w' (`kill-ring-save'), which
  743. copies the region into the kill ring without removing it from the
  744. buffer.  This is approximately equivalent to `C-w' followed by `C-x u',
  745. except that `M-w' does not alter the undo history and does not
  746. temporarily change the screen.
  747. File: emacs,  Node: Appending Kills,  Next: Earlier Kills,  Prev: Kill Ring,  Up: Yanking
  748. Appending Kills
  749. ---------------
  750.    Normally, each kill command pushes a new entry onto the kill ring.
  751. However, two or more kill commands in a row combine their text into a
  752. single entry, so that a single `C-y' yanks all the text as a unit, just
  753. as it was before it was killed.
  754.    Thus, if you want to yank text as a unit, you need not kill all of it
  755. with one command; you can keep killing line after line, or word after
  756. word, until you have killed it all, and you can still get it all back at
  757. once.
  758.    Commands that kill forward from point add onto the end of the
  759. previous killed text.  Commands that kill backward from point add text
  760. onto the beginning.  This way, any sequence of mixed forward and
  761. backward kill commands puts all the killed text into one entry without
  762. rearrangement.  Numeric arguments do not break the sequence of
  763. appending kills.  For example, suppose the buffer contains this text:
  764.      This is a line -!-of sample text.
  765. with point shown by -!-.  If you type `M-d M-DEL M-d M-DEL', killing
  766. alternately forward and backward, you end up with `a line of sample' as
  767. one entry in the kill ring, and `This is  text.' in the buffer.  (Note
  768. the double space, which you can clean up with `M-SPC' or `M-q'.)
  769.    Another way to kill the same text is to move back two words with
  770. `M-b M-b', then kill all four words forward with `C-u M-d'.  This
  771. produces exactly the same results in the buffer and in the kill ring.
  772. `M-f M-f C-u M-DEL' kills the same text, all going backward; once
  773. again, the result is the same.  The text in the kill ring entry always
  774. has the same order that it had in the buffer before you killed it.
  775.    If a kill command is separated from the last kill command by other
  776. commands (not just numeric arguments), it starts a new entry on the kill
  777. ring.  But you can force it to append by first typing the command
  778. `C-M-w' (`append-next-kill') right before it.  The `C-M-w' tells the
  779. following command, if it is a kill command, to append the text it kills
  780. to the last killed text, instead of starting a new entry.  With
  781. `C-M-w', you can kill several separated pieces of text and accumulate
  782. them to be yanked back in one place.
  783.    A kill command following `M-w' does not append to the text that
  784. `M-w' copied into the kill ring.
  785. File: emacs,  Node: Earlier Kills,  Prev: Appending Kills,  Up: Yanking
  786. Yanking Earlier Kills
  787. ---------------------
  788.    To recover killed text that is no longer the most recent kill, use
  789. the `M-y' command (`yank-pop').  It takes the text previously yanked
  790. and replaces it with the text from an earlier kill.  So, to recover the
  791. text of the next-to-the-last kill, first use `C-y' to yank the last
  792. kill, and then use `M-y' to replace it with the previous kill.  `M-y'
  793. is allowed only after a `C-y' or another `M-y'.
  794.    You can understand `M-y' in terms of a "last yank" pointer which
  795. points at an entry in the kill ring.  Each time you kill, the "last
  796. yank" pointer moves to the newly made entry at the front of the ring.
  797. `C-y' yanks the entry which the "last yank" pointer points to.  `M-y'
  798. moves the "last yank" pointer to a different entry, and the text in the
  799. buffer changes to match.  Enough `M-y' commands can move the pointer to
  800. any entry in the ring, so you can get any entry into the buffer.
  801. Eventually the pointer reaches the end of the ring; the next `M-y'
  802. moves it to the first entry again.
  803.    `M-y' moves the "last yank" pointer around the ring, but it does not
  804. change the order of the entries in the ring, which always runs from the
  805. most recent kill at the front to the oldest one still remembered.
  806.    `M-y' can take a numeric argument, which tells it how many entries
  807. to advance the "last yank" pointer by.  A negative argument moves the
  808. pointer toward the front of the ring; from the front of the ring, it
  809. moves "around" to the last entry and continues forward from there.
  810.    Once the text you are looking for is brought into the buffer, you can
  811. stop doing `M-y' commands and it will stay there.  It's just a copy of
  812. the kill ring entry, so editing it in the buffer does not change what's
  813. in the ring.  As long as no new killing is done, the "last yank"
  814. pointer remains at the same place in the kill ring, so repeating `C-y'
  815. will yank another copy of the same previous kill.
  816.    If you know how many `M-y' commands it would take to find the text
  817. you want, you can yank that text in one step using `C-y' with a numeric
  818. argument.  `C-y' with an argument restores the text the specified
  819. number of entries back in the kill ring.  Thus, `C-u 2 C-y' gets the
  820. next to the last block of killed text.  It is equivalent to `C-y M-y'.
  821. `C-y' with a numeric argument starts counting from the "last yank"
  822. pointer, and sets the "last yank" pointer to the entry that it yanks.
  823.    The length of the kill ring is controlled by the variable
  824. `kill-ring-max'; no more than that many blocks of killed text are saved.
  825.    The actual contents of the kill ring are stored in a variable named
  826. `kill-ring'; you can view the entire contents of the kill ring with the
  827. command `C-h v kill-ring'.
  828. File: emacs,  Node: Accumulating Text,  Next: Rectangles,  Prev: Yanking,  Up: Top
  829. Accumulating Text
  830. =================
  831.    Usually we copy or move text by killing it and yanking it, but there
  832. are other methods convenient for copying one block of text in many
  833. places, or for copying many scattered blocks of text into one place.  To
  834. copy one block to many places, store it in a register (*note
  835. Registers::.).  Here we describe the commands to accumulate scattered
  836. pieces of text into a buffer or into a file.
  837. `M-x append-to-buffer'
  838.      Append region to contents of specified buffer.
  839. `M-x prepend-to-buffer'
  840.      Prepend region to contents of specified buffer.
  841. `M-x copy-to-buffer'
  842.      Copy region into specified buffer, deleting that buffer's old
  843.      contents.
  844. `M-x insert-buffer'
  845.      Insert contents of specified buffer into current buffer at point.
  846. `M-x append-to-file'
  847.      Append region to contents of specified file, at the end.
  848.    To accumulate text into a buffer, use `M-x append-to-buffer'.  This
  849. reads a buffer name, them inserts a copy of the region into the buffer
  850. specified.  If you specify a nonexistent buffer, `append-to-buffer'
  851. creates the buffer.  The text is inserted wherever point is in that
  852. buffer.  If you have been using the buffer for editing, the copied text
  853. goes into the middle of the text of the buffer, wherever point happens
  854. to be in it.
  855.    Point in that buffer is left at the end of the copied text, so
  856. successive uses of `append-to-buffer' accumulate the text in the
  857. specified buffer in the same order as they were copied.  Strictly
  858. speaking, `append-to-buffer' does not always append to the text already
  859. in the buffer--only if point in that buffer is at the end.  However, if
  860. `append-to-buffer' is the only command you use to alter a buffer, then
  861. point is always at the end.
  862.    `M-x prepend-to-buffer' is just like `append-to-buffer' except that
  863. point in the other buffer is left before the copied text, so successive
  864. prependings add text in reverse order.  `M-x copy-to-buffer' is similar
  865. except that any existing text in the other buffer is deleted, so the
  866. buffer is left containing just the text newly copied into it.
  867.    To retrieve the accumulated text from another buffer, use `M-x
  868. insert-buffer'; this too takes BUFFERNAME as an argument.  It inserts a
  869. copy of the text in buffer BUFFERNAME into the selected buffer.  You
  870. can alternatively select the other buffer for editing, then optionally
  871. move text from it by killing.  *Note Buffers::, for background
  872. information on buffers.
  873.    Instead of accumulating text within Emacs, in a buffer, you can
  874. append text directly into a file with `M-x append-to-file', which takes
  875. FILENAME as an argument.  It adds the text of the region to the end of
  876. the specified file.  The file is changed immediately on disk.
  877.    You should use `append-to-file' only with files that are *not* being
  878. visited in Emacs.  Using it on a file that you are editing in Emacs
  879. would change the file behind Emacs's back, which can lead to losing
  880. some of your editing.
  881.